<%-- 
    Document   : DealTheoDanhMuc
    Created on : Oct 20, 2011, 10:08:24 AM
    Author     : Administrator
--%>

<%@page import="java.text.DecimalFormat"%>
<%@page import="dao.Deal_DAO"%>
<%@page import="pojo.Deal"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<div class="div_topLBestPrice"></div>
<div id="divRecentDeal">
    <ul class='ul_listBestPrice'>
        <%
            ArrayList<Deal> ds = (ArrayList<Deal>) request.getAttribute("dealTheoDanhMuc");
            // ArrayList<Deal> ds = Deal_DAO.layDSDealGanDay();
            for (int i = 0; i < ds.size(); i++) {
                Deal deal = new Deal();
                deal = ds.get(i);
                double giaThuong = deal.getGiaThuong();
                double giaDaGiam = deal.getGiaDaGiam();
                double tietKiem = giaThuong - giaDaGiam;
                double a = 100 - (giaDaGiam / giaThuong) * 100;
                int phanTram = (int) a;
                DecimalFormat df = new DecimalFormat(",###");
                String giaThuong1 = String.valueOf(df.format(giaThuong));
                String giaDaGiam1 = String.valueOf(df.format(giaDaGiam));
                String tietKiem1 = String.valueOf(df.format(tietKiem));
                if (i % 2 == 0) {

        %>
        <li class='li_ListBP'>
            <div class='div_topListBP'></div>
            <div class='div_bodyListBP'>
                <div class='div_bodyLineRound'></div>
                <div class='div_infoListBP'>
                    <div class='div_LBodyListBP'>
                        <div class='div_TietKiem'>
                            <strong class='styleText14'>Tiết Kiệm</strong><br/>
                            <strong class='styleText15'><%=phanTram%>%</strong>
                        </div>
                        <div class='divPrice'>
                            <span class='styleText17'>
                                Giá trị:<strong class='StyleTextGT lineHorizontal styleText13'><%=giaThuong1%></strong>
                            </span>
                            <div class='div_VND GTVND'>
                                <strong class='styleText16'>VND</strong>
                            </div><br/>
                            <span class='styleText17 spTietKiem'>
                                Tiết kiệm:<strong class='StyleTextGT styleText13'><%=tietKiem1%></strong>
                            </span>
                            <div class='div_VND TKVND'>
                                <strong class='styleText16'>VND</strong>
                            </div>
                        </div>
                        <div class='div_infoMoney'>
                            <div class='div_TextInfoMoney'>
                                <p class='styleText14'>
                                    <strong>Còn Lại</strong>
                                    <!--<strong class='strTextVND'>VND</strong>-->
                                </p>
                                <p class='pGiaTien'><strong class='styleText5' ><%=giaDaGiam1%></strong></p>
                            </div>
                        </div>
                        <p class='color9 styleText9 pWasBuyer'><strong>2000</strong></p>
                        <p class='pWasBuyer color9 styleText14'>Người mua giá tốt</p>
                    </div>
                    <div class='div_RBodyListBP'>
                        <p  class='pTextInfoList styleText8'>
                            <a href='xl_DealDetail?Action=view&DealID=<%=deal.getId()%>' title='<%=deal.getTileSmallDeal()%> <%=phanTram%> %'><%=deal.getTileSmallDeal()%> <%=phanTram%> %</a>
                        </p>
                        <div class='div_imgListBP'>
                            <a href='xl_DealDetail?Action=view&DealID=<%=deal.getId()%>'>
                                <i class='iChayHang'></i>
                                <img width='229' alt='xl_DealDetail?Action=view&DealID=<%=deal.getId()%>' height='140' src='<%=deal.getHinhDaiDien()%>'>
                            </a>
                        </div>
                        <p class='styleText13 pDayCity'><%=deal.getNgayBatDau()%></p>
                    </div> 
                </div>
            </div>
            <div class='div_bottomListBP'></div>
        </li>
        <%} else {%>
        <li class='li_RlistBP li_ListBP'>
            <div class='div_topListBP'></div>
            <div class='div_bodyListBP'>
                <div class='div_bodyLineRound'></div>
                <div class='div_infoListBP'>
                    <div class='div_LBodyListBP'>
                        <div class='div_TietKiem'>
                            <strong class='styleText14'>Tiết Kiệm</strong><br/>
                            <strong class='styleText15'><%=phanTram%> %</strong>
                        </div>
                        <div class='divPrice'>
                            <span class='styleText17'>
                                Giá trị:<strong class='StyleTextGT lineHorizontal styleText13'><%=giaThuong1%></strong>
                            </span>
                            <div class='div_VND GTVND'>
                                <strong class='styleText16'>VND</strong>
                            </div><br/>
                            <span class='styleText17 spTietKiem'>
                                Tiết kiệm:<strong class='StyleTextGT styleText13'><%=tietKiem1%></strong>
                            </span>
                            <div class='div_VND TKVND'>
                                <strong class='styleText16'>VND</strong>
                            </div>
                        </div>
                        <div class='div_infoMoney'>
                            <div class='div_TextInfoMoney'>
                                <p class='styleText14'>
                                    <strong>Còn Lại</strong>
                                    <!--<strong class='strTextVND'>VND</strong>-->
                                </p>
                                <p class='pGiaTien'>
                                    <strong class='styleText5' ><%=giaDaGiam1%></strong>
                                </p>
                            </div>
                        </div>
                        <p class='color9 styleText9 pWasBuyer'>
                            <strong>713</strong>
                        </p>
                        <p class='pWasBuyer color9 styleText14'>Người mua giá tốt</p>
                    </div>
                    <div class='div_RBodyListBP'>
                        <p  class='pTextInfoList styleText8'>
                            <a href='xl_DealDetail?Action=view&DealID=<%=deal.getId()%>' title='<%=deal.getTileSmallDeal()%> <%=phanTram%> %'><%=deal.getTileSmallDeal()%> <%=phanTram%> %</a>
                        </p>
                        <div class='div_imgListBP'>
                            <a href='xl_DealDetail?Action=view&DealID=<%=deal.getId()%>'><img width='229' alt='<%=deal.getTileSmallDeal()%> <%=phanTram%> %' height='140' src='<%=deal.getHinhDaiDien()%>'></a>
                        </div>
                        <p class='styleText13 pDayCity'><%=deal.getNgayBatDau()%></p>
                    </div> 
                </div>
            </div>
            <div class='div_bottomListBP'></div>
        </li>
        <%}
            }%>
    </ul>
    <%    if (request.getAttribute("SoTrang") != null) {
            String temp = String.valueOf(request.getAttribute("SoTrang"));
            int soTrang = Integer.parseInt(temp);
            String temp2 = String.valueOf(request.getAttribute("MaDanhMuc"));
            int maDanhMuc = Integer.parseInt(temp2);
    %>
     
    <div class='div_buttonBP' id='divPaging'>
        <div class='div_aListPage' id='div_aListPage'>
            <% for (int i = 0; i < soTrang; i++){%>
           
            <a href='xl_DealTheoDanhMuc?Action=view&ID=<%=maDanhMuc%>&Trang=<%=i+1%>'><%=i+1%></a>
            <% }%>
            <a class='a_buttonNextBP' href='2.html'>
                <div class='div_icon_NextBP'></div>
            </a>
        </div>
    </div>
            <%}%>
</div>
